package com.wanshi.controller;

import com.wanshi.pojo.Stu;
import com.wanshi.service.StuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/stu")
public class stuController {

   @Autowired
    StuService stuService;

    @RequestMapping("/getStuList")
    public List<Stu> getStuList(){
        List<Stu> stuList = stuService.getStuList();
        return stuList;
    }

    @RequestMapping("/getStuById")
    public String getStuById(Integer stu_id){
        stuService.getStuById(stu_id);
        return "查询单个";
    }

    @RequestMapping("/addStu")
    public String addStu(Stu stu){
        stuService.addStu(stu);
        return "添加成功";
    }

    @RequestMapping("/delStu")
    public String delStu(Integer stu_id){
        stuService.delStuById(stu_id);
        return "删除成功";
    }

    @RequestMapping("/updateById")
    public String updateById(Integer stu_id){
        stuService.updateStuById(stu_id);
        return "修改成功";
    }

}
